home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-03-20 | 7.2 KB | 258 lines | [TEXT/KAHL] |
- //#define DEBUG 1
- // Defininions for 'puriTEXT'
- // Copyright (C) 1994 by Mizutori Tetsuya, 94/3/9, 94/3/21
-
- // Define macros
-
- // general constants
- #define kMoveToFront (WindowPtr)-1L
- #define kNilFilterProc nil
- #define kNilActionProc nil
- #define kScrollBarWidth 16
- #define kShiftHorizontal 0
- #define kShiftVertical 0
- #define kShiftDItem 16384
- #define kLimitDItem 8192
- #define kSleep MAXLONG
- #define kVisible true
- #define kStartValue 1
- #define kMinValue 1
- #define kEmptyTitle "\p"
- #define kEmptyString "\p"
- #define kNilOSType ((OSType) nil)
- #define kNilAppleEvent nil
- #define kNilAppleEventID 0
- #define kCheckMark 0xC3 /* option-v */
- #define plain 0
-
- #define kDisableButton 255
- #define kEnableButton 0
- #define kGestaltMask 1L
-
- // special parameters
- #define kNilRefCon 0L
- #define kMyRefCon 10098L /* a random unique number */
- #define kNormalMode 0
- #define kPrefMode 1
- #define kMaxCreators 16
-
- #define kScrollStep1 1
- #define kScrollStep2 4
-
- // error messages in 'STR#'
- #define kErrCode (128L << 16)
- #define kErrSetEOF kErrCode+1
- #define kErrMaxCreators kErrCode+2
- #define kMsgSurePurify kErrCode+3
- #define kErrFileSystem kErrCode+4
- #define kErrAppleEvent kErrCode+5
-
- // labels of puriTEXT in 'STR#'
- #define kLabel (129L << 16)
- #define kLabelHelp kLabel+1
- #define kLabelPref kLabel+2
- #define kLabelFont kLabel+3
- #define kLabelCheck kLabel+4
- #define kLabelDoc kLabel+5
- #define kLabelSaveAs kLabel+6
-
- // resource IDs
- #define kAlertID 1000
- #define kWindowID 128
- #define kDialogID 128
- #define kAboutID 129
- #define kNoteAlertID 130
- #define kCautionAlertID 131
- #define kMenuBarID 128
- #define kMenuID 128
- #define kTextID 128
- #define kPrefType 'PREF'
- #define kPrefID 128
- #define mApple kMenuID+0
- #define mFile kMenuID+1
- #define mEdit kMenuID+2
- #define mCreator kMenuID+3
- #define mExclude kMenuID+4
-
- // item number in menus
- // Apple Menu
- #define iAbout 1
- #define iDeskAcc 3
- // File Menu
- #define iNew 1
- #define iOpen 2
- #define iClose 4
- #define iSave 5
- #define iSaveAs 6
- #define iRevert 7
- #define iPageSetup 9
- #define iPrint 10
- #define iPreferences 12
- #define iQuit 14
- // Edit Menu
- #define iUndo 1
- #define iCut 3
- #define iCopy 4
- #define iPaste 5
- #define iClear 6
- #define iDuplicate 8
- #define iSelectAll 9
- // Creators popup menu
- #define ipcAdd 1
- #define ipcAppend 2
- #define ipcRemove 3
- #define ipcFirst 5
- // Exclude popup menu
- #define ipeAdd 1
- #define ipeAppend 2
- #define ipeRemove 3
- #define ipeEnable 4
- #define ipeDisable 5
- #define ipeFirst 7
-
- // items in the main dialog
- #define iUserItem 3
- #define iTitle 4
- #define iIcon 5
- #define iCopyright 6
- #define iVersion 7
- #define iDummy 8
- #define iPref 9
- #define iCBCreator 10
- #define iCBModDate 11
- #define iCBBigRF 12
- #define iCBExclude 13
- #define iTextKB 19
- #define iTBCreator 14
- #define iTBBigRF 15
- #define iTBExclude 16
- #define iSWCreator 17
- #define iSWExclude 18
- #define iPopupCreator 20
- #define iPopupExclude 21
-
-
- // datablock structures
- typedef struct {
- Rect rect; // Window position
- Boolean check[4]; // Status of checkBox[0..3]
- OSType creator; // Creator, eg. 'ttxt'
- OSType exclude; // Creator, eg. 'MzpT'
- long sizeRF; // Alert condition
- long flag; // Enable/Disable flags for Exludes[]
- OSType creators[kMaxCreators];
- OSType excludes[kMaxCreators];
- } PrefDataRecord, *PrefDataPtr;
-
-
- typedef struct {
- DialogRecord dialog;
- CursPtr iBeam;
- RgnHandle iBeamRgn;
- short mode;
- short userItem;
- ControlHandle userCntl;
- TEHandle userTE;
- short **posHndl;
- PrefDataRecord pref;
- } myWindowRecord, myDialogRecord;
-
- typedef myWindowRecord *myWindowPeek, *myWindowPtr;
- typedef myDialogRecord *myDialogPeek, *myDialogPtr;
-
-
- // Definition for macro functions
- #define my(window,field) (((myWindowPeek)window)->field)
-
- #define ShiftValue(window,curVal,newVal) \
- ( (*my(window,posHndl))[newVal-kMinValue] \
- - (*my(window,posHndl))[curVal-kMinValue] )
- // ( newVal - curVal )
-
- #define TypToString(t,s) { s[0]=4; BlockMove(&t,&s[1],4); }
- #define StringToTyp(s,t) { BlockMove(&s[1],t,4); }
- // !!! CAUSION !!! Usage: StringToTyp(text,&type);
-
- //#define TopLeft( r ) (* (Point *) &(r).top)
- //#define BottomRight( r ) (* (Point *) &(r).bottom)
-
- pascal OSErr SetDialogDefaultItem( DialogPtr dialog, short item ) =
- { 0x303C, 0x0304, 0xAA68 };
- pascal OSErr SetDialogCancelItem( DialogPtr dialog, short item ) =
- { 0x303C, 0x0305, 0xAA68 };
- pascal OSErr SetDialogTracksCursor( DialogPtr dialog, Boolean tracks ) =
- { 0x303C, 0x0306, 0xAA68 };
-
-
- // Prototypes (generals.c)
- /***** Do Error Messages *****/
- void ErrorMessage( OSErr err, StringPtr string, Boolean fatal );
- void StopMessage( long errCode, StringPtr str1, StringPtr str2,long value );
- void NoteMessage( long errCode, StringPtr str1, StringPtr str2,long value );
- Boolean CautionMessage( long errCode, StringPtr str1, StringPtr str2,long value );
- void SetupParam( long errCode, StringPtr str1, StringPtr str2, long value );
- /***** Gestalt check *****/
- void GestaltCheck( OSType gestaltCode );
- /***** Get Text from resource *****/
- StringPtr GetIndText( long code, StringPtr text );
- /***** Pstring *****/
- //void TypToString( OSType type, StringPtr str );
- //void StringToTyp( StringPtr str, OSType *type );
- StringPtr Pstrcpy( StringPtr dst, const StringPtr src );
- StringPtr Pstrcat( StringPtr dst, const StringPtr src );
- short Pstrcmp( const StringPtr dst, const StringPtr src );
- short Pstrncmp( const StringPtr dst, const StringPtr src, Size k );
- /***** Read & Write resource *****/
- Boolean LoadRsrcPREF( PrefDataPtr dataBlock );
- void SaveRsrcPREF( PrefDataPtr dataBlock );
- /***** Window operations *****/
- void GetWindowRect( WindowPtr window, Rect *rect );
- /***** Dialog operations *****/
- Handle IGetTxtHand( DialogPtr dialog, short item );
- ControlHandle IGetCtlHand( DialogPtr dialog, short item );
- /***** Standard File Get & Put *****/
- Boolean GetFileDialog( short numTypes, SFTypeList typeList, FSSpec *theFSSpec );
- Boolean PutFileDialog( StringPtr prompt, Boolean *replacing, FSSpec *theFSSpec );
- /***** Menu Operation *****/
- short GetMenuInd( MenuHandle menu, StringPtr text );
- short TrackPopupMenu( ControlHandle theCntl );
-
- // Prototypes (modelessDialog.c)
- Boolean ModelessDialog( DialogPtr dialog, EventRecord *event, short *item );
- Boolean IsDialogEdit( DialogPtr dialog, EventRecord *event );
- pascal Boolean MyDialogFilter( DialogPtr dialog, EventRecord *event, short *item );
-
- // Prototypes (scrollTE.c)
- void SetupText( WindowPtr window, short textID, Rect *rect, TEHandle *teHandle );
- short SetupLinePos( WindowPtr window, TEHandle teHndl, Handle *posHndl );
- void TEScrollProc( WindowPtr window, Point thePoint );
- pascal void myScrollProc( ControlHandle theControl, short thePart );
- void SetControl( ControlHandle theControl, short *shift );
-
- // Prototypes (dialogList.c)
- void listDialog( DialogPtr dialog );
-
- // Prototypes (errorCode.c)
- StringPtr ErrFS( OSErr errCode );
- StringPtr ErrAE( OSErr errCode );
-
-
- #ifdef DEBUG
- /***** DEBUG messages *****/
- char * DBScrollPart( short thePart );
- char * DBEventWhat( short what );
- char * DBosEvent( long message );
- char * DBMouseDown( short thePart );
- char * DBFileMenu( short item );
- char * DBEditMenu( short item );
- char * DBDITLType( short itemType );
- char * DBAppleEventClass( OSType item );
- #endif DEBUG
-
- #ifdef DEBUG
- #include <stdio.h>
- #include <console.h>
- #endif DEBUG
-
- // end of definitions
-